/**
 */
package fUML.Semantics.CommonBehaviors.Communications.impl;

import fUML.Semantics.Classes.Kernel.KernelPackage;

import fUML.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;

import fUML.Semantics.CommonBehaviors.Communications.ClassifierBehaviorExecution;
import fUML.Semantics.CommonBehaviors.Communications.CommunicationsPackage;
import fUML.Semantics.CommonBehaviors.Communications.EventAccepter;
import fUML.Semantics.CommonBehaviors.Communications.ObjectActivation;
import fUML.Semantics.CommonBehaviors.Communications.SignalInstance;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Object Activation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fUML.Semantics.CommonBehaviors.Communications.impl.ObjectActivationImpl#getWaitingEventAccepters <em>Waiting Event Accepters</em>}</li>
 *   <li>{@link fUML.Semantics.CommonBehaviors.Communications.impl.ObjectActivationImpl#getEventPool <em>Event Pool</em>}</li>
 *   <li>{@link fUML.Semantics.CommonBehaviors.Communications.impl.ObjectActivationImpl#getObject <em>Object</em>}</li>
 *   <li>{@link fUML.Semantics.CommonBehaviors.Communications.impl.ObjectActivationImpl#getClassifierBehaviorExecutions <em>Classifier Behavior Executions</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ObjectActivationImpl extends EObjectImpl implements ObjectActivation {
	/**
	 * The cached value of the '{@link #getWaitingEventAccepters() <em>Waiting Event Accepters</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getWaitingEventAccepters()
	 * @generated
	 * @ordered
	 */
	protected EList<EventAccepter> waitingEventAccepters;

	/**
	 * The cached value of the '{@link #getEventPool() <em>Event Pool</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEventPool()
	 * @generated
	 * @ordered
	 */
	protected EList<SignalInstance> eventPool;

	/**
	 * The cached value of the '{@link #getClassifierBehaviorExecutions() <em>Classifier Behavior Executions</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClassifierBehaviorExecutions()
	 * @generated
	 * @ordered
	 */
	protected EList<ClassifierBehaviorExecution> classifierBehaviorExecutions;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ObjectActivationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CommunicationsPackage.Literals.OBJECT_ACTIVATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EventAccepter> getWaitingEventAccepters() {
		if (waitingEventAccepters == null) {
			waitingEventAccepters = new EObjectResolvingEList<EventAccepter>(EventAccepter.class, this, CommunicationsPackage.OBJECT_ACTIVATION__WAITING_EVENT_ACCEPTERS);
		}
		return waitingEventAccepters;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SignalInstance> getEventPool() {
		if (eventPool == null) {
			eventPool = new EObjectContainmentEList<SignalInstance>(SignalInstance.class, this, CommunicationsPackage.OBJECT_ACTIVATION__EVENT_POOL);
		}
		return eventPool;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public fUML.Semantics.Classes.Kernel.Object getObject() {
		if (eContainerFeatureID() != CommunicationsPackage.OBJECT_ACTIVATION__OBJECT) return null;
		return (fUML.Semantics.Classes.Kernel.Object)eContainer();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetObject(fUML.Semantics.Classes.Kernel.Object newObject, NotificationChain msgs) {
		msgs = eBasicSetContainer((InternalEObject)newObject, CommunicationsPackage.OBJECT_ACTIVATION__OBJECT, msgs);
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setObject(fUML.Semantics.Classes.Kernel.Object newObject) {
		if (newObject != eInternalContainer() || (eContainerFeatureID() != CommunicationsPackage.OBJECT_ACTIVATION__OBJECT && newObject != null)) {
			if (EcoreUtil.isAncestor(this, newObject))
				throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
			NotificationChain msgs = null;
			if (eInternalContainer() != null)
				msgs = eBasicRemoveFromContainer(msgs);
			if (newObject != null)
				msgs = ((InternalEObject)newObject).eInverseAdd(this, KernelPackage.OBJECT__OBJECT_ACTIVATION, fUML.Semantics.Classes.Kernel.Object.class, msgs);
			msgs = basicSetObject(newObject, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CommunicationsPackage.OBJECT_ACTIVATION__OBJECT, newObject, newObject));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ClassifierBehaviorExecution> getClassifierBehaviorExecutions() {
		if (classifierBehaviorExecutions == null) {
			classifierBehaviorExecutions = new EObjectContainmentWithInverseEList<ClassifierBehaviorExecution>(ClassifierBehaviorExecution.class, this, CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS, CommunicationsPackage.CLASSIFIER_BEHAVIOR_EXECUTION__OBJECT_ACTIVATION);
		}
		return classifierBehaviorExecutions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void startBehavior(fUML.Syntax.Classes.Kernel.Class classifier, EList<ParameterValue> inputs) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void stop() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void register(EventAccepter accepter) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void unregister(EventAccepter accepter) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void send(SignalInstance signalInstance) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispatchNextEvent() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SignalInstance getNextEvent() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void _startObjectBehavior() {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void _send(Object signal) {
		// TODO: implement this method
		// Ensure that you remove @generated or mark it @generated NOT
		throw new UnsupportedOperationException();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				if (eInternalContainer() != null)
					msgs = eBasicRemoveFromContainer(msgs);
				return basicSetObject((fUML.Semantics.Classes.Kernel.Object)otherEnd, msgs);
			case CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getClassifierBehaviorExecutions()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CommunicationsPackage.OBJECT_ACTIVATION__EVENT_POOL:
				return ((InternalEList<?>)getEventPool()).basicRemove(otherEnd, msgs);
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				return basicSetObject(null, msgs);
			case CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS:
				return ((InternalEList<?>)getClassifierBehaviorExecutions()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
		switch (eContainerFeatureID()) {
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				return eInternalContainer().eInverseRemove(this, KernelPackage.OBJECT__OBJECT_ACTIVATION, fUML.Semantics.Classes.Kernel.Object.class, msgs);
		}
		return super.eBasicRemoveFromContainerFeature(msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CommunicationsPackage.OBJECT_ACTIVATION__WAITING_EVENT_ACCEPTERS:
				return getWaitingEventAccepters();
			case CommunicationsPackage.OBJECT_ACTIVATION__EVENT_POOL:
				return getEventPool();
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				return getObject();
			case CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS:
				return getClassifierBehaviorExecutions();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CommunicationsPackage.OBJECT_ACTIVATION__WAITING_EVENT_ACCEPTERS:
				getWaitingEventAccepters().clear();
				getWaitingEventAccepters().addAll((Collection<? extends EventAccepter>)newValue);
				return;
			case CommunicationsPackage.OBJECT_ACTIVATION__EVENT_POOL:
				getEventPool().clear();
				getEventPool().addAll((Collection<? extends SignalInstance>)newValue);
				return;
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				setObject((fUML.Semantics.Classes.Kernel.Object)newValue);
				return;
			case CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS:
				getClassifierBehaviorExecutions().clear();
				getClassifierBehaviorExecutions().addAll((Collection<? extends ClassifierBehaviorExecution>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case CommunicationsPackage.OBJECT_ACTIVATION__WAITING_EVENT_ACCEPTERS:
				getWaitingEventAccepters().clear();
				return;
			case CommunicationsPackage.OBJECT_ACTIVATION__EVENT_POOL:
				getEventPool().clear();
				return;
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				setObject((fUML.Semantics.Classes.Kernel.Object)null);
				return;
			case CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS:
				getClassifierBehaviorExecutions().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CommunicationsPackage.OBJECT_ACTIVATION__WAITING_EVENT_ACCEPTERS:
				return waitingEventAccepters != null && !waitingEventAccepters.isEmpty();
			case CommunicationsPackage.OBJECT_ACTIVATION__EVENT_POOL:
				return eventPool != null && !eventPool.isEmpty();
			case CommunicationsPackage.OBJECT_ACTIVATION__OBJECT:
				return getObject() != null;
			case CommunicationsPackage.OBJECT_ACTIVATION__CLASSIFIER_BEHAVIOR_EXECUTIONS:
				return classifierBehaviorExecutions != null && !classifierBehaviorExecutions.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //ObjectActivationImpl
